#coding:utf-8
'''
* coder  : dzlua
* email  : 505544956@qq.com
* module : api-frame
* path   : app/utils
* file   : response.py
* time   : 2017-11-08 13:19:11
'''
#--------------------#
from flask import jsonify as __jsonify
#--------------------#

#--------------------#
R200_OK = {'code': 200, 'message': 'OK'}
R400_BADREQUEST = {'code': 400, 'message': 'Bad Request'}
R401_UNAUTHORIZED = {'code': 401, 'message': 'Unauthorized'}
R403_FORBIDDEN = {'code': 403, 'message': 'Forbidded'}
R404_NOTFOUND = {'code': 404, 'message': 'Not Found'}
R405_MethordNotAllow = {'code': 405, 'message': 'Method Not Allowed'}
R409_Conflict = {'code': 409, 'message': 'Conflict'}
#--------------------#

#--------------------#
def makeResponse(statu_dic, data=None, msg=None, jsonify=False):
    if msg:
        statu_dic['message'] = msg
    #
    tdata = { 'status': statu_dic }
    if data:
        tdata = { 'status': statu_dic, 'data': data }
    #
    if jsonify:
       return __jsonify(tdata), statu_dic['code']
    else:
       return tdata, statu_dic['code']
#--------------------#
